<template>
	<view class="master flex-column flex-aligin-items-center">
		<view class="flex-row master-box">
			<view class="master-img">
				<image src="../../../static/img/master.svg" class="fun-img"></image>
			</view>
			<view class="master-text flex-column flex-space-between">
				<text class="fun-font-14px text-size flex-row">{{master}}</text>
				<view class="text-name flex-row">
					<text class="fun-font-14px">{{mdesignation}}</text>
					<text class="fun-font-14px text-size ">{{masterMsg.name}}</text>
				</view>
				<view class="text-name flex-row">
					<text class="fun-font-14px">{{workname}}</text>
					<text class="fun-font-14px text-size">{{masterMsg.number}}</text>
				</view>
			</view>
		</view>
		<view class="master-btn flex-row">
			<text class="fun-font-14px ptext">{{phonenumber}}</text>
			<text class="fun-font-14px text-phone">{{masterMsg.phone}}</text>
			<button @click="masterbtn(masterMsg.phone)" class="btn-m">{{phonebtn}}</button>
		</view>
	</view>
</template>

<script>
	import {
		getEngineerserById
	} from '@/api/user/index.js'
	export default {
		data() {
			return {
				eid: '', //设备id
				engineer_id: '', //工程师id
				masterMsg: [],
				master: '维修工程师',
				mdesignation: '姓名:',
				mastername: '姓名xxx',
				workname: '工号:',
				wx: '123xxxxx',
				phonebtn: '拨号',
				phonenumber: '手机号',
				goback: '返回'
			}
		},
		onLoad(op) {
			this.engineer_id = this.$store.getters.getEquipmentInfo.engineer_id
			console.log(this.engineer_id)
			getEngineerserById(this.engineer_id).then((res) => {
				this.masterMsg = res.result[this.engineer_id]
				console.log(res)
			})
		},
		methods: {
			masterbtn(phone) {
				console.log(phone)
				uni.makePhoneCall({
					// 手机号
					phoneNumber: phone,
					// 成功回调
					success: (res) => {
						console.log('调用成功!')
					},
					// 失败回调
					fail: (res) => {
						console.log('调用失败!')
						uni.reLaunch({
							url: '/pages/index/maintain/maintain'
						})
					}
				});

				/* if(phone!=''){
					
				}else{
					uni.reLaunch({
					url:'../maintain/maintain'
					})
				}	 */
				/* uni.reLaunch({
				url:'/pages/index/maintain/maintain'
				}) */
			},
		}
	}
</script>

<style lang="scss" scoped>
	.master {
		width: 100%;
		height: 100%;
		background-color: #f1f1f1;

		.master-box {
			background-color: #FFFFFF;
			width: 100%;
			height: 300rpx;
			padding: 22rpx 30rpx;
			border-bottom: 2rpx solid #999999;

			.master-img {
				height: 160rpx;
				width: 40%;
			}

			.master-text {
				height: 160rpx;
				width: 60%;
			}

		}

		.master-btn {
			width: 100%;
			background-color: #FFFFFF;
			height: 100rpx;

			.ptext {
				width: 15%;
				line-height: 100rpx;
				padding-left: 20rpx;
			}

			.text-phone {
				width: 40%;
				height: 100rpx;
				line-height: 100rpx;
			}

			.btn-m {
				width: 40%;
				line-height: 75rpx;
				height: 75rpx;
				color: #FFFFFF;
				background-color: #48C23D;
			}
		}


	}
</style>
